package thread;

public class DeadLock {

	private Object[] lock = new Object[0];
	
	private Thread t = new Thread(){
		public void run() {
			System.out.println(getName() + "准备锁定资源");
			synchronized(lock) {
				System.out.println("啊哦，死锁了，这条语句看来是打不出来了");
			}
		}
	};
	
	public DeadLock() {
		synchronized(lock) {
			System.out.println(Thread.currentThread().getName() + "锁定了资源");
			try {
				t.start();
				t.join();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
	
	public static void main(String[] args) {
		new DeadLock();
	}
	
}
